#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>

static void *(*lt_malloc) (size_t size);
 
__attribute__ ((constructor))
static void init_mem_func (void) 
{
	lt_malloc = (void *(*)(size_t))dlsym(RTLD_NEXT, "malloc");
}
 
void *malloc(size_t size)
{ 
	if(lt_malloc == NULL){
		init_mem_func();
	}
	void *ptr;
	ptr = lt_malloc(size);
	printf("malloc size(%d) at (%p)\n", size, ptr);
	return ptr;
}
